import numpy as np
import pandas as pd
from decision_tree import Decision_Tree
#数据集dataset
#https://archive.ics.uci.edu/dataset/14/breast+cancer
data_set = pd.read_csv('MLbase\\dataset\\breast+cancer\\breast-cancer.data')
print(data_set)
feature_names = ['Class','age','menopause','tumor-size',
        'inv-nodes','node-caps','deg-malig','breast','breast-quad']
label_name = 'irradiat'

x_train = data_set[:250]
print(x_train)

t = Decision_Tree()
tree = t.build_tree(x_train,label_name,feature_names)

x_test = data_set[250:][feature_names]
y_test = data_set[250:][label_name]

true_num = 0
for i,sample in enumerate(x_test.values):
    result = t.classify(tree,sample,feature_names)
    print(result)
    if result==y_test.values[i]:
        true_num += 1
print(true_num/y_test.shape[0])
